package com.yanqu.road.server.manager.activity.hsisland.handler.impl;

import com.yanqu.road.entity.activity.hsisland.HsIslandExploreResult;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandConfig;
import com.yanqu.road.entity.activity.hsisland.data.HsIslandEventData;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivity;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandIsland;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerReq;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerResp;
import com.yanqu.road.server.manager.activity.hsisland.handler.HsIslandIEventHandler;

public class HsIslandEventChooseHandler implements HsIslandIEventHandler {

    /**
     * 探索后处理
     * @param req
     * @return
     */
    @Override
    public HsIslandExploreResult explore(HsIslandExploreHandlerReq req) {
        CrossHsIslandActivity activity = req.getActivity();
        HsIslandConfig config = activity.getConfig();
        HsIslandEventData eventData = req.getEventData();
        CrossHsIslandIsland island = req.getIsland();
        //事件注入坐标
        eventData.addPosition(req.getX(), req.getY());
        //随机一个2选1配置ID
        int chooseConfigId = config.getRandomChooseConfigId();
        //事件注入2选1配置ID
        eventData.setChooseConfigId(chooseConfigId);
        //岛屿注入事件
        island.putEvent(eventData);
        //返回
        HsIslandExploreResult resp = new HsIslandExploreResult();
        resp.addEventData(eventData);
        return resp;
    }
}
